<html>
<head>
<meta charset="UTF-8">
<title>数据运维定时配置修改</title>
	<link  id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/css/esaas-easyui-edit.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<body class="easyui-layout" scroll="no">
<form id="tt" method="post">
	<div class="esaas-info-title">数据运维mysql配置信息</div>
	<table class="esaas-info-edit-table">
		<tr>
			<td width="15%" align="right">MySQL数据库IP：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="baseIP" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">数据库名称：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="databaseName" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">用户名：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="username" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">用户密码：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="password" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">备份路径：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="savePath" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
	</table>
</form>
<form id="ff" method="post">
	<div class="esaas-info-title">数据运维定时配置信息</div>
	<table class="esaas-info-edit-table">
		<tr>
			<td width="15%" align="right">定时作业编号：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobCode" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">定时作业描述：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobDesc" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">服务节点标识：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="agentId" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">Cron表达式：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="cronExpression" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>

		</tr>
		<tr>
			<td width="15%" align="right">作业类类型：</td>
			<td width="35%"><select class="easyui-combobox"
									id="jobClassType" name="jobClassType"
									style="width: 100%; height: 25px;"
									data-options="required:true,editable:false,valueField:'enname',textField:'cnname',data:JOB_CLASS_TYPE, onSelect: onChangeJobType">
			</select></td>
			<td width="15%" align="right"><span id="serviceVersionLabel">服务版本：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text" id="serviceVersion"
								   name="serviceVersion" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">作业实现类：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobClass" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">作业类方法：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobMethod" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right"><span id="serviceGroupLabel">服务组别：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text" id="serviceGroup"
								   name="serviceGroup" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="18%" align="right"><span id="serviceTimeoutLabel">服务超时时间(毫秒)：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text" id="serviceTimeout"
								   name="serviceTimeout" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">失败重试次数：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="againTime" data-options="required:true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">重试间隔秒数：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="retrySecond" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">作业状态：</td>
			<td width="35%"><select class="easyui-combobox"
									id="jobState" name="jobState"
									style="width: 100%; height: 25px;"
									data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:JOB_STATE">
			</select></td>
			<td width="15%" align="right">耗时（秒）：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="costTime" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">上一次执行时间：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="lastExecuteTime" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">下一次执行时间：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="nextExecuteTime" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>

		<tr>
			<td width="15%" align="right">所属系统：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="subsCode" id="subsCode" data-options="required:true,disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">备注：</td>
			<td width="85%" colspan="3"><input class="easyui-textbox" type="text"
											   name="remark" data-options="required:false, multiline: true"
											   style="width: 100%; height: 50px;"></input></td>
		</tr>
	</table>
</form>
	<div style="text-align: center; padding: 15px">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			onclick="submitForm()">&nbsp;保&nbsp;存&nbsp;</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			onclick="closeForm()">&nbsp;关&nbsp;闭&nbsp;</a>
	</div>
	<script>		
		$(function() {
			var jobCode = $.getUrlParam('jobCode');
			$.restfulGet('../../api/dbo/backup/conf/' + jobCode,null,function(data){
				$('#tt').form('load', {
					baseIP : data.rows.baseIP,
					databaseName : data.rows.databaseName,
					username : data.rows.username,
					password : data.rows.password,
					savePath : data.rows.savePath
				});
			});
			$.restfulGet('../../api/s/srvs/cron/conf/' + jobCode,null,function(data){
				$('#ff').form('load', {
					jobCode : data.rows.jobCode,
					jobDesc : data.rows.jobDesc,
					jobClassType : data.rows.jobClassType,
					jobClass : data.rows.jobClass,
					jobMethod : data.rows.jobMethod,
					serviceVersion : data.rows.serviceVersion,
					serviceGroup : data.rows.serviceGroup,
					serviceTimeout : data.rows.serviceTimeout,
					cronExpression : data.rows.cronExpression,
					againTime : data.rows.againTime,
					retrySecond : data.rows.retrySecond,
					agentId : data.rows.agentId,
					subsCode:data.rows.subsCode,
					remark : data.rows.remark,
					jobState : data.rows.jobState,
					lastExecuteTime : data.rows.lastExecuteTime,
					nextExecuteTime : data.rows.nextExecuteTime,
					costTime : data.rows.costTime
				});
				onChangeJobType({enname: data.rows.jobClassType})
			});
		});
	
		function submitForm() {
			if (!$('#ff').form('validate')|| !$('#tt').form('validate'))
				return;
			var jsonData = $("#tt").serializeJson();
			var jsonDataTimed=$("#ff").serializeJson();
			jsonData.subsCode=jsonDataTimed.subsCode;
			jsonData.jobCode=jsonDataTimed.jobCode;
			$.restfulPut('../../api/s/srvs/cron/conf', jsonDataTimed, function(data) {
				window.parent.reloadList();
			});
			$.restfulPut('../../api/dbo/backup/conf',jsonData, function(data) {
			});

		};

		function onChangeJobType(data){
			console.log(data);
			if(data && (data.enname == 'hsf' || data.enname == 'dubbo')) {
				$("#serviceVersionLabel").show();
				$("#serviceVersion").next().show();
				$("#serviceGroupLabel").show();
				$("#serviceGroup").next().show();
				$("#serviceTimeoutLabel").show();
				$("#serviceTimeout").next().show();

				$("#serviceVersion").textbox('textbox').validatebox({required: true});
			} else {
				$("#serviceVersionLabel").hide();
				$("#serviceVersion").next().hide();
				$("#serviceGroupLabel").hide();
				$("#serviceGroup").next().hide();
				$("#serviceTimeoutLabel").hide();
				$("#serviceTimeout").next().hide();

				$("#serviceVersion").textbox('textbox').validatebox({required: false});
				$("#serviceVersion").textbox('setValue', '');
				$("#serviceGroup").textbox('setValue', '');
				$("#serviceTimeout").textbox('setValue', '');
			}
		}
		
		function closeForm(){
			window.parent.JLEUtil.closewin();
		}
	</script>
</body>
</html>
